package work;

import java.util.ArrayList;
import java.util.Scanner;
//oopday7课堂练习 -> ArrayList的使用
public class ArrayListWork {
    public static void main(String[] args) {
        ArrayList<String> stringlist = new ArrayList<>();
        stringlist.add("第一个元素");
        stringlist.add("第二个元素");
        stringlist.add("第三个元素");
        System.out.print("stringlist的元素有：");
        for (int i = 0; i < stringlist.size(); i++) {
            System.out.print(stringlist.get(i)+" ");
        }
        System.out.println("\n--------------------");
        ArrayList<Student> studentlist = new ArrayList<>();
        Scanner console = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            System.out.print("请输入学生的姓名和年龄：（以空格分隔）");
            studentlist.add(new Student(console.next(),console.nextInt()));
        }
        for (int i = 0; i < stringlist.size(); i++) {
            System.out.print("第" + (i+1) + "个");
            System.out.print(studentlist.get(i).toString());
        }
    }
}